/**
 * @author 谷其昊
 * @version 1.0
 * @date 2022/1/20
 * @time 15:19
 */
public class ArrayTest {
    public static void main(String[] args) {
        int[] arr = {3, 4, 5, 99, 2, 1};
        MyTools myTools = new MyTools();
        myTools.bubble(arr);
    }
}

class MyTools {
    public void bubble(int[] arr) {
        for (int i = 1; i < arr.length; i++) {
            for (int j = 1; j <= arr.length - i; j++) {
                int temp = 0;
                if (arr[j - 1] > arr[j]) {
                    temp = arr[j];
                    arr[j] = arr[j - 1];
                    arr[j - 1] = temp;
                }
            }
        }

        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
    }
}
